<script setup>
import { ref } from 'vue'
const loading = ref(false)
const prop = defineProps({
    function: {
        type: Function,
        default: () => { }
    },
    type:{
        type:String,
        default:'primary'
    }
})

async function request() {
    if (loading.value == true) {
        return
    }
    loading.value = true
    await prop.function()
    loading.value = false
}
</script>

<template>
    <el-button v-if="loading == false" @click="request" :type="type">
        <slot></slot>
    </el-button>
    <el-button v-else loading @click="request" :type="type">
        <slot></slot>
    </el-button>
</template>

<style scoped lang="less">

</style>

